/* GUI CONVERTED from xxprvpct.p (converter v1.75) Fri Apr 13 12:22:46 2001 */
/* xxprvpct.p - PR SUPPLIER SPLIT % MAINTENANCE                           */
/* $Revision: 1.7.1.8 $                                                   */
/*V8:ConvertMode=Maintenance                                              */
/* REVISION: 9.1      LAST MODIFIED: 06/10/03   BY: *CLI* cli             */

/* DISPLAY TITLE */
{mfdtitle.i "b+ "}

define variable del-yn like mfc_logical initial no.
define variable adname like ad_name.
define variable adname2 like ad_name.
define variable adname3 like ad_name.
define variable adname4 like ad_name.
define variable adname5 like ad_name.

/* Variable added to perform delete during CIM.
 * Record is deleted only when the value of this variable
 * Is set to "X" */
define variable batchdelete as character format "x(1)" no-undo.

/* DISPLAY SELECTION FORM */

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
   prdiv_site     colon 25
   si_desc        AT 48 NO-LABEL SKIP
   prdiv_part     colon 25  
   pt_desc1       AT 48 NO-LABEL SKIP
   pt_desc2       AT 48 NO-LABEL SKIP(1)
   prdiv_vend     COLON 10 SPACE(1)
   adname        NO-LABEL
   prdiv_ord_min
   prdiv_pct AT 71 NO-LABEL
   "%" skip
   prdiv_vend2     COLON 10 SPACE(1)
   adname2        NO-LABEL
   prdiv_ord_min2
   prdiv_pct2      AT 71 NO-LABEL
   "%" skip
   prdiv_vend3     COLON 10 SPACE(1)
   adname3        NO-LABEL
   prdiv_ord_min3 
   prdiv_pct3      AT 71 NO-LABEL
   "%" skip
   prdiv_vend4     COLON 10 SPACE(1)
   adname4        NO-LABEL
   prdiv_ord_min4
   prdiv_pct4      AT 71 NO-LABEL
   "%" skip
   prdiv_vend5     COLON 10 SPACE(1)
   adname5        NO-LABEL
   prdiv_ord_min5
   prdiv_pct5      AT 71 NO-LABEL
   "%" skip

 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* DISPLAY */
view frame a.
mainloop:
repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* Initialize delete flag before each display of frame */
   batchdelete = "".

   /* Prompt for the delete variable in the key frame at the
   * End of the key field/s only when batchrun is set to yes */
   prompt-for prdiv_site
              prdiv_part
              batchdelete no-label when (batchrun)
   editing:
      /* FIND NEXT/PREVIOUS RECORD */
      
      if frame-field = "prdiv_site" then do:
         /* FIND NEXT/PREVIOUS RECORD */
          {mfnp.i prdiv_mstr prdiv_site prdiv_site prdiv_site prdiv_site
           prdiv_sitepart}
      end.
      else do:
         /* FIND NEXT/PREVIOUS RECORD */
         {mfnp05.i prdiv_mstr prdiv_sitepart "prdiv_site = input prdiv_site and
          prdiv_part = input prdiv_part" prdiv_part "input prdiv_part"}
      end.
      if recno <> ? then do:                                                  
         display prdiv_site prdiv_part prdiv_vend prdiv_pct prdiv_ord_min                 
         prdiv_vend2 prdiv_pct2 prdiv_ord_min2                                              
         prdiv_vend3 prdiv_pct3 prdiv_ord_min3                                               
         prdiv_vend4 prdiv_pct4 prdiv_ord_min4                                               
         prdiv_vend5 prdiv_pct5 prdiv_ord_min5.                                              
                                                                          
         find si_mstr where input prdiv_site = si_site no-lock no-error.      
         display si_desc when (available si_mstr).                            
         find pt_mstr no-lock where input prdiv_part = pt_part no-error.      
         display pt_desc1 when (available pt_mstr).                           
         find ad_mstr where ad_addr = prdiv_vend no-lock no-error.            
         if available ad_mstr then                                            
            display ad_name @ adname.                                         
         else                                                                 
            display "" @ adname 0 @ prdiv_pct 0 @ prdiv_ord_min.                                
         find ad_mstr where ad_addr = prdiv_vend2 no-lock no-error.           
         if available ad_mstr then                                            
         display ad_name @ adname2.                                           
         else                                                                 
            display "" @ adname2 0 @ prdiv_pct2 0 @ prdiv_ord_min2.                              
         find ad_mstr where ad_addr = prdiv_vend3 no-lock no-error.           
         if available ad_mstr then                                            
         display ad_name @ adname3.                                           
         else                                                                 
            display "" @ adname3 0 @ prdiv_pct3 0 @ prdiv_ord_min3.                              
         find ad_mstr where ad_addr = prdiv_vend4 no-lock no-error.           
         if available ad_mstr then                                            
         display ad_name @ adname4.                                           
        else                                                                  
            display "" @ adname4 0 @ prdiv_pct4 0 @ prdiv_ord_min4.                              
         find ad_mstr where ad_addr = prdiv_vend5 no-lock no-error.           
         if available ad_mstr then                                            
         display ad_name @ adname5.                                           
        else                                                                  
            display "" @ adname5 0 @ prdiv_pct5 0 @ prdiv_ord_min5.                              
      end. /* if recno <> ? then do: */                                      
   end. /* editing: */

   /* ADD/MOD/DELETE  */
   find first prdiv_mstr where prdiv_site = input prdiv_site and
      prdiv_part = input prdiv_part no-error.
   if not available prdiv_mstr then do:
      display "" @ adname 0 @ prdiv_pct 0 @ prdiv_ord_min 
              "" @ adname2 0 @ prdiv_pct2 0 @ prdiv_ord_min2 
              "" @ adname3 0 @ prdiv_pct3 0 @ prdiv_ord_min3 
              "" @ adname4 0 @ prdiv_pct4 0 @ prdiv_ord_min4 
              "" @ adname5 0 @ prdiv_pct5 0 @ prdiv_ord_min5    
      with frame a. 
      {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}
      create prdiv_mstr.
      assign prdiv_part
             prdiv_site.
   end. /* if not available prdiv_mstr then do: */

   /* STORE MODIFY DATE AND USERID */
   prdiv_mod_date = today.
   prdiv_userid = global_userid.
  
   find si_mstr where si_site = input frame a prdiv_site
      no-lock no-error.
   if not available si_mstr then do: 
       {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}
        next-prompt prdiv_site with frame a.
        undo mainloop, retry.
   end. 
 
   find pt_mstr where pt_part = input frame a prdiv_part
        no-lock no-error.
   if not available pt_mstr then do:
      {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
      next-prompt prdiv_part with frame a.
      undo mainloop, retry.

   end.   /*  IF NOT AVAILABLE VD_MSTR  */
  
/* SET GLOBAL PART VARIABLE */
   global_part = pt_part.

   display prdiv_site prdiv_part prdiv_vend prdiv_pct prdiv_ord_min
             prdiv_vend2 prdiv_pct2 prdiv_ord_min2 
             prdiv_vend3 prdiv_pct3 prdiv_ord_min3
             prdiv_vend4 prdiv_pct4 prdiv_ord_min4
             prdiv_vend5 prdiv_pct5 prdiv_ord_min5.
 
   find si_mstr where si_site = prdiv_site no-lock no-error.
      display si_desc when (available si_mstr).
   find pt_mstr no-lock where pt_part = prdiv_part no-error.
      display pt_desc1 when (available pt_mstr)
   pt_desc2 when (available pt_mstr).
   find ad_mstr where ad_addr = prdiv_vend no-lock no-error.           
   if available ad_mstr then                                           
      display ad_name @ adname.
   else
      display "" @ adname 0 @ prdiv_pct 0 @ prdiv_ord_min.                           
   find ad_mstr where ad_addr = prdiv_vend2 no-lock no-error.          
   if available ad_mstr then                                           
      display ad_name @ adname2.
   else
      display "" @ adname2 0 @ prdiv_pct2 0 @ prdiv_ord_min2.                           
   find ad_mstr where ad_addr = prdiv_vend3 no-lock no-error.          
   if available ad_mstr then                                           
      display ad_name @ adname3.                                          
   else
      display "" @ adname3 0 @ prdiv_pct3 0 @ prdiv_ord_min3.                           
 
   find ad_mstr where ad_addr = prdiv_vend4 no-lock no-error.          
   if available ad_mstr then                                           
      display ad_name @ adname4.                                          
   else
      display "" @ adname4 0 @ prdiv_pct4 0 @ prdiv_ord_min4.                           
 
   find ad_mstr where ad_addr = prdiv_vend5 no-lock no-error.          
   if available ad_mstr then                                           
      display ad_name @ adname5.                                          
   else
      display "" @ adname5 0 @ prdiv_pct5 0 @ prdiv_ord_min5.                           
 
   recno = recid(prdiv_mstr).

   ststatus = stline[2].
   status input ststatus.
   del-yn = no.

   seta:
   do on error undo, retry:
/*GUI*/if global-beam-me-up then undo, leave.
     set 
     prdiv_vend  prdiv_ord_min      prdiv_pct  
     prdiv_vend2 prdiv_ord_min2     prdiv_pct2 
     prdiv_vend3 prdiv_ord_min3     prdiv_pct3 
     prdiv_vend4 prdiv_ord_min4     prdiv_pct4 
     prdiv_vend5 prdiv_ord_min5     prdiv_pct5 
     go-on("F5" "CTRL-D" ) editing:
       if frame-field = "prdiv_pct"  or 
          frame-field = "prdiv_pct2" or 
          frame-field = "prdiv_pct3" or 
          frame-field = "prdiv_pct4" or
          frame-field = "prdiv_pct5" then do:
      
          if input prdiv_vend <> "" then do: 
          find ad_mstr where input prdiv_vend = ad_addr no-lock no-error. 
          if available ad_mstr then                                       
             display ad_name @ adname.                                    
          else do:                                                        
             {mfmsg.i 2 3}                                                
             next-prompt prdiv_vend.                                      
             display "" @ adname 0 @ prdiv_pct 0 @ prdiv_ord_min.                           
          end.                       
          end.
          else  display "" @ adname 0 @ prdiv_pct 0 @ prdiv_ord_min.                           
         
          if input prdiv_vend2 <> "" then do:                              
          find ad_mstr where input prdiv_vend2 = ad_addr no-lock no-error.
          if available ad_mstr then                                       
             display ad_name @ adname2.                                   
          else do:                                                        
            {mfmsg.i 2 3}                                                
            next-prompt prdiv_vend2.                                     
            display "" @ adname2 0 @ prdiv_pct2 0 @ prdiv_ord_min2.                         
          end.                                                            
          end.     
          else  display "" @ adname2 0 @ prdiv_pct2 0 @ prdiv_ord_min2.                           
 
          if input prdiv_vend3 <> "" then do:                                                        
          find ad_mstr where input prdiv_vend3 = ad_addr no-lock no-error.
          if available ad_mstr then                                       
             display ad_name @ adname3.                                   
          else do:                                                        
             {mfmsg.i 2 3}                                                
             next-prompt prdiv_vend3.                                     
             display "" @ adname3 0 @ prdiv_pct3 0 @ prdiv_ord_min3.                         
          end.           
          end.                                                 
          else  display "" @ adname3 0 @ prdiv_pct3 0 @ prdiv_ord_min3.                           

          if input prdiv_vend4 <> "" then do:                                                             
          find ad_mstr where input prdiv_vend4 = ad_addr no-lock no-error.
          if available ad_mstr then                                       
             display ad_name @ adname4.                                   
          else do:                                                        
             {mfmsg.i 2 3}                                                
             next-prompt prdiv_vend4.                                     
             display "" @ adname4 0 @ prdiv_pct4 0 @ prdiv_ord_min4.                         
          end.                                                            
          end.
          else  display "" @ adname4 0 @ prdiv_pct4 0 @ prdiv_ord_min4.                           
          
          if input prdiv_vend5 <> "" then do:                                                             
          find ad_mstr where input prdiv_vend5 = ad_addr no-lock no-error.
          if available ad_mstr then                                       
             display ad_name @ adname5.                                   
          else do:                                                        
             {mfmsg.i 2 3}                                                
             next-prompt prdiv_vend5.                                     
             display "" @ adname5 0 @ prdiv_pct5 0 @ prdiv_ord_min5.                         
          end.
          end. 
          else  display "" @ adname5 0 @ prdiv_pct5 0 @ prdiv_ord_min5.                           
 
       end.                                                     
       readkey.
       apply lastkey.
     end. /* Editing */
     /* VALUE MUST BE EQUAL TO 100% */      
     if (input prdiv_pct + input prdiv_pct2 + input prdiv_pct3 + input prdiv_pct4 + input prdiv_pct5) <> 100 then do:
        {mfmsg.i 8180 3}
        next-prompt prdiv_pct.
        undo, retry seta.
     end.
           
     if input prdiv_vend <> "" then do: 
        find ad_mstr where input prdiv_vend = ad_addr no-lock no-error. 
        if not available ad_mstr then do:                                      
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend.                                      
           display "" @ adname 0 @ prdiv_pct 0 @ prdiv_ord_min.                           
           undo, retry seta.
        end.                       
     end.
     else do:
        if input prdiv_pct > 0 or input prdiv_ord_min > 0 then do:
          {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend.                                      
           display "" @ adname 0 @ prdiv_pct 0 @ prdiv_ord_min.                           
           undo, retry seta.
        end.                       
     end.
    
     if input prdiv_vend2 <> "" then do:                              
        find ad_mstr where input prdiv_vend2 = ad_addr no-lock no-error.
        if not available ad_mstr then do:                                     
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend2.                                     
           display "" @ adname2 0 @ prdiv_pct2 0 @ prdiv_ord_min2.
           undo, retry seta.
        end.                                                            
     end.
     else do:
        if input prdiv_pct2 > 0 or input prdiv_ord_min2 > 0 then do:
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend2.                                     
           display "" @ adname2 0 @ prdiv_pct2 0 @ prdiv_ord_min2.
           undo, retry seta.
        end.                                                            
     end.

     
     if input prdiv_vend3 <> "" then do:                                                        
        find ad_mstr where input prdiv_vend3 = ad_addr no-lock no-error.
        if not available ad_mstr then do:                                      
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend3.                                     
           display "" @ adname3 0 @ prdiv_pct3 0 @ prdiv_ord_min3.                         
           undo, retry seta.
        end.           
     end.
     else do:
        if input prdiv_pct3 > 0 or input prdiv_ord_min3 > 0 then do:
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend3.                                     
           display "" @ adname3 0 @ prdiv_pct3 0 @ prdiv_ord_min3.                         
           undo, retry seta.
        end.           
     
     end.

     if input prdiv_vend4 <> "" then do:                                                             
        find ad_mstr where input prdiv_vend4 = ad_addr no-lock no-error.
        if not available ad_mstr then do:                                      
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend4.                                     
           display "" @ adname4 0 @ prdiv_pct4 0 @ prdiv_ord_min4.                         
          undo, retry seta.
        end.                                                            
     end.
     else do:
        if input prdiv_pct4 > 0 or input prdiv_ord_min4 > 0 then do:
            {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend4.                                     
           display "" @ adname4 0 @ prdiv_pct4 0 @ prdiv_ord_min4.                         
          undo, retry seta.
        end.                                                            
     end.

     if input prdiv_vend5 <> "" then do:                                                             
        find ad_mstr where input prdiv_vend5 = ad_addr no-lock no-error.
        if not available ad_mstr then do:                                     
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend5.                                     
           display "" @ adname5 0 @ prdiv_pct5 0 @ prdiv_ord_min5.                         
           undo, retry seta.
        end.
     end.
     else do:
        if input prdiv_pct5 > 0 or input prdiv_ord_min5 > 0 then do:
           {mfmsg.i 2 3}                                                
           next-prompt prdiv_vend5.                                     
           display "" @ adname5 0 @ prdiv_pct5 0 @ prdiv_ord_min5.                         
           undo, retry seta.
        end.
     end.
        
     if prdiv_pct > 100 or prdiv_pct2 > 100 or
        prdiv_pct3 > 100 or prdiv_pct4 > 100  or
        prdiv_pct5 > 100 then do:
        {pxmsg.i &MSGNUM=2803 &ERRORLEVEL=3}
        /* VALUE CAN NOT BE GREATER THAN 100% */
        next-prompt prdiv_pct.
        undo, retry.
     end.
     
     /* DELETE */
     /* Delete to be executed if batchdelete is set or
     * F5 or CTRL-D pressed */
     if lastkey = keycode("F5") or lastkey = keycode("CTRL-D")
        or input batchdelete = "x":U
     then do:
        del-yn = yes.
        {mfmsg01.i 11 1 del-yn}
        if not del-yn then undo seta.
        delete prdiv_mstr.
        clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
        del-yn = no.
        next mainloop.
     end. /* lastkey = keycode("F5") */
   end.   /* do on error undo, retry: */
/*GUI*/ if global-beam-me-up then undo, leave.
end.      /* repeat with frame a: */
/*GUI*/ if global-beam-me-up then undo, leave.
status input.
